import json
import requests

url = 'http://localhost:8000/upload_huwai/'
file_path = 'D:\\desktop\\test_1\\meiquan (45).jpg'

with open(file_path, 'rb') as file:
    files = {'file': file}  # requests会自动处理Content-Type和boundary
    response = requests.post(url, files=files)
# 确保请求成功
if response.status_code == 200:
    # 将响应内容解析为Python对象
    data = response.json()

    # 将Python对象保存为JSON文件
    with open('output.json', 'w', encoding='utf-8') as json_file:
        json.dump(data, json_file, ensure_ascii=False, indent=4)
else:
    print(f"请求失败，状态码：{response.status_code}")
    print(response.text)